//
//  BaseTableViewCell.m
//  WIFI
//
//  Created by linnzh on 2023/3/27.
//

#import "BaseTableViewCell.h"

@interface BaseTableViewCell ()

//@property (nonatomic, strong) UIView *backView;

@end

@implementation BaseTableViewCell

+ (CGSize)cellSize {
    return CGSizeZero;
}

+ (NSValue *)cellSizeValue {
    return [NSValue valueWithCGSize:[self cellSize]];
}

+ (NSString *)cellIdentifier {
    return [NSString stringWithFormat:@"%@", [self class]];
}

+ (void)registerCellInTableView:(UITableView *)tableView {
    [tableView registerClass:[self class] forCellReuseIdentifier:[self cellIdentifier]];
}

+ (instancetype)cellWithIndexPath:(NSIndexPath *)indexPath atTableView:(UITableView *)tableView {
    return [tableView dequeueReusableCellWithIdentifier:[self cellIdentifier] forIndexPath:indexPath];
}

- (instancetype)init {
    if (self = [super init]) {
        [self setupCell];
        [self setupSubviews];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupCell];
        [self setupSubviews];
    }
    return self;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupCell];
        [self setupSubviews];
    }
    return self;
}

- (void)setupCell {
    for (UIView *view in self.subviews) {
        if([view isKindOfClass:[UIScrollView class]]) {
            ((UIScrollView *)view).delaysContentTouches = NO; // Remove touch delay for iOS 7
            break;
        }
    }
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundView.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    self.backgroundColor = [UIColor clearColor];
    
    if (@available(iOS 14.0, *)) {
        self.backgroundConfiguration = [UIBackgroundConfiguration clearConfiguration];
    } else {
        // Fallback on earlier versions
    }
    
//    [self.contentView addSubview:self.backView];
}

- (void)setupSubviews {
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
//    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.mas_equalTo(self.contentView.mas_leading);
//        make.trailing.mas_equalTo(self.contentView.mas_trailing);
//        make.top.mas_equalTo(self.contentView.mas_top);
//        make.bottom.mas_equalTo(self.contentView.mas_bottom);
//    }];
}
//
//#pragma mark - Lazy loading
//- (UIView *)backView {
//    if (!_backView) {
//        _backView = [[UIView alloc] init];
//        _backView.backgroundColor = [UIColor clearColor];
//    }
//    return _backView;
//}

@end
